define([
  'jquery',
  'angular',
  'ngSanitize',
  'service/main'
], function ($, angular) {
  var controller = angular.module('postController', [
      'ngSanitize',
      'post'
    ]);
  controller.controller('ListController', [
    '$scope',
    'Post',
    function ($scope, Post) {
      $scope.isReady = false;
      Post.getList().success(function (data) {
        $scope.isReady = true;
        $scope.posts = data;
      }).error(function (e) {
        console.error(e);
      });
    }
  ]).controller('DetailController', [
    '$scope',
    '$stateParams',
    'Post',
    function ($scope, $stateParams, Post) {
      $scope.isReady = false;
      Post.getNode($stateParams.nid).success(function (data) {
        $scope.isReady = true;
        $scope.post = data;
      }).error(function (e) {
        console.log(e);
      });
    }
  ]);
  return controller;
});